package com.java.tutorials.jdk7.paths;

import java.net.URI;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Created by xuzhike on 2016/1/27.
 * http://www.java2s.com/Code/Java/JDK-7/Managingsymboliclinks.htm
 * Managing symbolic links
 */
public class Managingsymboliclinks {
    public static void main(String[] args) throws Exception {
        Path path1 = Paths.get("/home/docs/users.txt");
        Path path2 = Paths.get("/home/music/users.txt");

        System.out.println(Files.isSymbolicLink(path1));
        System.out.println(Files.isSymbolicLink(path2));

        Path path = Paths.get(new URI("C:/home/./music/users.txt"));
        System.out.println("Normalized: " + path.normalize());
        System.out.println("Absolute path: " + path.toAbsolutePath());
        System.out.println("URI: " + path.toUri());
        System.out.println("toRealPath (Do not follow links): "+ path.toRealPath(LinkOption.NOFOLLOW_LINKS));
        System.out.println("toRealPath: " + path.toRealPath());


    }
}
